home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Milan_1991 / Devcon91.2 / Network / Socket / include / netinet / ip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-01  |  4.7 KB  |  153 lines

  1. /*
  2.  * Copyright (c) 1982, 1986 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  *
  17.  *    @(#)ip.h    7.6.1.3 (Berkeley) 2/20/89
  18.  */
  19. #ifndef BYTE_ORDER
  20. /*
  21.  * Definitions for byte order,
  22.  * according to byte significance from low address to high.
  23.  */
  24. #define    LITTLE_ENDIAN    1234    /* least-significant byte first (vax) */
  25. #define    BIG_ENDIAN    4321    /* most-significant byte first (IBM, net) */
  26. #define    PDP_ENDIAN    3412    /* LSB first in word, MSW first in long (pdp) */
  27.  
  28. #ifdef vax
  29. #define    BYTE_ORDER    LITTLE_ENDIAN
  30. #else
  31. #define    BYTE_ORDER    BIG_ENDIAN    /* mc68000, tahoe, most others */
  32. #endif
  33. #endif BYTE_ORDER
  34.  
  35. /*
  36.  * Definitions for internet protocol version 4.
  37.  * Per RFC 791, September 1981.
  38.  */
  39. #define    IPVERSION    4
  40.  
  41. /*
  42.  * Structure of an internet header, naked of options.
  43.  *
  44.  * We declare ip_len and ip_off to be short, rather than u_short
  45.  * pragmatically since otherwise unsigned comparisons can result
  46.  * against negative integers quite easily, and fail in subtle ways.
  47.  */
  48. struct ip {
  49. #ifdef LATTICE
  50.     int    ip_v:4;            /* version */
  51.     int    ip_hl:4;        /* header length */
  52.     int    ip_tos:8;        /* type of service */
  53.     int    ip_len:16;        /* length */
  54. #elif AZTEC_C            /* conviently just the opposite of Lattice */
  55.     int ip_len    :16;
  56.     int    ip_tos    :8;        /* type of service */
  57.     int    ip_hl    :4;        /* header length */
  58.     int    ip_v    :4;        /* version */
  59. #else
  60.     short    ip_tos:8,        /* type of service */
  61.         ip_hl:4,        /* header length */
  62.         ip_v:4;            /* version */
  63.     short    ip_len;            /* total length */
  64. #endif    /* LATTICE */
  65.     u_short    ip_id;            /* identification */
  66.     short    ip_off;            /* fragment offset field */
  67. #define    IP_DF 0x4000            /* dont fragment flag */
  68. #define    IP_MF 0x2000            /* more fragments flag */
  69.     u_char    ip_ttl;            /* time to live */
  70.     u_char    ip_p;            /* protocol */
  71.     u_short    ip_sum;            /* checksum */
  72.     struct    in_addr ip_src,ip_dst;    /* source and dest address */
  73. };
  74.  
  75. #define    IP_MAXPACKET    65535        /* maximum packet size */
  76.  
  77. /*
  78.  * Definitions for options.
  79.  */
  80. #define    IPOPT_COPIED(o)        ((o)&0x80)
  81. #define    IPOPT_CLASS(o)        ((o)&0x60)
  82. #define    IPOPT_NUMBER(o)        ((o)&0x1f)
  83.  
  84. #define    IPOPT_CONTROL        0x00
  85. #define    IPOPT_RESERVED1        0x20
  86. #define    IPOPT_DEBMEAS        0x40
  87. #define    IPOPT_RESERVED2        0x60
  88.  
  89. #define    IPOPT_EOL        0        /* end of option list */
  90. #define    IPOPT_NOP        1        /* no operation */
  91.  
  92. #define    IPOPT_RR        7        /* record packet route */
  93. #define    IPOPT_TS        68        /* timestamp */
  94. #define    IPOPT_SECURITY        130        /* provide s,c,h,tcc */
  95. #define    IPOPT_LSRR        131        /* loose source route */
  96. #define    IPOPT_SATID        136        /* satnet id */
  97. #define    IPOPT_SSRR        137        /* strict source route */
  98.  
  99. /*
  100.  * Offsets to fields in options other than EOL and NOP.
  101.  */
  102. #define    IPOPT_OPTVAL        0        /* option ID */
  103. #define    IPOPT_OLEN        1        /* option length */
  104. #define IPOPT_OFFSET        2        /* offset within option */
  105. #define    IPOPT_MINOFF        4        /* min value of above */
  106.  
  107. /*
  108.  * Time stamp option structure.
  109.  */
  110. struct    ip_timestamp {
  111.     u_char    ipt_code;        /* IPOPT_TS */
  112.     u_char    ipt_len;        /* size of structure (variable) */
  113.     u_char    ipt_ptr;        /* index of current entry */
  114. #if BYTE_ORDER == LITTLE_ENDIAN 
  115.     u_int    ipt_flg:4,        /* flags, see below */
  116.         ipt_oflw:4;        /* overflow counter */
  117. #endif
  118. #if BYTE_ORDER == BIG_ENDIAN 
  119.     u_int    ipt_oflw:4,        /* overflow counter */
  120.         ipt_flg:4;        /* flags, see below */
  121. #endif
  122.     union ipt_timestamp {
  123.         n_long    ipt_time[1];
  124.         struct    ipt_ta {
  125.             struct in_addr ipt_addr;
  126.             n_long ipt_time;
  127.         } ipt_ta[1];
  128.     } ipt_timestamp;
  129. };
  130.  
  131. /* flag bits for ipt_flg */
  132. #define    IPOPT_TS_TSONLY        0        /* timestamps only */
  133. #define    IPOPT_TS_TSANDADDR    1        /* timestamps and addresses */
  134. #define    IPOPT_TS_PRESPEC    3        /* specified modules only */
  135.  
  136. /* bits for security (not byte swapped) */
  137. #define    IPOPT_SECUR_UNCLASS    0x0000
  138. #define    IPOPT_SECUR_CONFID    0xf135
  139. #define    IPOPT_SECUR_EFTO    0x789a
  140. #define    IPOPT_SECUR_MMMM    0xbc4d
  141. #define    IPOPT_SECUR_RESTR    0xaf13
  142. #define    IPOPT_SECUR_SECRET    0xd788
  143. #define    IPOPT_SECUR_TOPSECRET    0x6bc5
  144.  
  145. /*
  146.  * Internet implementation parameters.
  147.  */
  148. #define    MAXTTL        255        /* maximum time to live (seconds) */
  149. #define    IPFRAGTTL    60        /* time to live for frags, slowhz */
  150. #define    IPTTLDEC    1        /* subtracted when forwarding */
  151.  
  152. #define    IP_MSS        576        /* default maximum segment size */
  153.